#------ Makefile; ida examples

# vpath %.c . # 源代码的查找目录
VPATH = .:./build
OUTPUT_DIR = build

# 伪目标
all: obj_exe
.PHONY : clean all

# ----- gcc 选项
CFLAGS := -lsundials_ida -lsundials_nvecopenmp -lsundials_nvecserial -lm -Og -g
# .o 目标文件
objects := $(patsubst %.c, %.o, $(wildcard *.c)) 
# .exe 可执行文件
obj_exe := $(patsubst %.c, %.exe, $(wildcard *.c))

# --- xxx.c -> xxx.o
$(objects): %.o:%.c $(OUTPUT_DIR)
	$(CC) -c $(CFLAGS) $< -o $(OUTPUT_DIR)/$@
# --- xxx.o -> xxx.exe
obj_exe:$(obj_exe)
$(obj_exe): $(objects)
	$(CC) $(OUTPUT_DIR)/$< $(CFLAGS) -o $(OUTPUT_DIR)/$@

# 构建目录
$(OUTPUT_DIR):
	mkdir $(OUTPUT_DIR)

#清理
clean:
	-rm build/*